/*
 * vim: ts=4 sw=4 ai noet tw=78
 * $Coar$
 */
#ifndef LDAPENTER_LDE_LDIF_H
#define LDAPENTER_LDE_LDIF_H 1
#include <lber.h>
#include "extern.h"
/*
 * LDIF writing macros:
 * - Write add and delete attributes for a given attribute name
 * - Write delete attribute for an objectClass attribute
 * - Write an entry continuation (modification of the entry corresponding to
 *   the same DN)
 * All macros are smart about the "compact" format being active or not.
 */
#define LDE_WRITE_ADD_DELETE(__ctx, __name, __len) do { \
	if( ! (__ctx)->opt_compact ) { \
		lde_write_ldif(__ctx, LDIF_PUT_VALUE, "delete", __name, __len); \
		lde_write_ldif(__ctx, LDIF_PUT_VALUE, "add", __name, __len); \
	} \
} while(0);
#define LDE_WRITE_DELETE_OC(__ctx) do { \
	if( ! (__ctx)->opt_compact ) { \
		lde_write_ldif(__ctx, LDIF_PUT_VALUE, "delete", "objectClass", 11); \
	} \
} while(0);

#define LDE_WRITE_CONTINUE(__ctx) do { \
	if( ! (__ctx)->opt_compact ) { \
		fputs("-\n", ctx->opt_file); \
	} \
} while(0);


void lde_write_ldif(runtime_t *, int, char *, char *, ber_len_t);
#endif
